<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: UserFacade.cfc 1194 2007-07-18 04:54:47Z pfarrell $

Notes:
--->
<cfcomponent
	displayname="UserFacade"
	output="false"
	hint="UserFacade component for MachBlog">
	
	<!---
	INITIALIZATION / CONFIGURATION
	--->
	<cffunction name="init" access="public" output="false" returntype="UserFacade" 
		hint="Constructor for this CFC">		
		<cfreturn this />
	</cffunction>
	
	<!---
	PUBLIC FUNCTIONS
	--->
	<cffunction name="removeUser" access="public" output="false" returntype="void" 
		hint="Removes the user object from the session">
		<cfset StructDelete(session, "user", false) />
	</cffunction>
	
	<cffunction name="userExists" access="public" output="false" returntype="boolean" 
		hint="Returns a boolean indicating whether or not there is a user object in the session 
			and if the user object has something other than null for the user id">

		<cfset var userExists = false />
			
		<cfif StructKeyExists(session, "user") AND session.user.getUserId() NEQ "">
			<cfset userExists = true />
		</cfif>
		
		<cfreturn userExists />
	</cffunction>
	
	<!---
	ACCESSORS
	--->
	<cffunction name="setUser" access="public" output="false" returntype="void" 
		hint="Puts the user object passed in into the session">
		<cfargument name="user" type="org.machblog.user.User" required="true" />
		<cfset session.user = arguments.user />
	</cffunction>
	<cffunction name="getUser" access="public" output="false" returntype="org.machblog.user.User" 
		hint="Gets user object from session">
		<cfreturn session.user />
	</cffunction>
		
</cfcomponent>